package edu.nanyang.dao;

import edu.nanyang.domain.StudentAnswer;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface StudentAnswerDao {
    //使用@Insert注解指明add方法要执行的SQL
    @Insert("insert into student_answer(student_num_id,question_num_id,answer_type,student_score,create_time) values(#{studentNumId},#{questionNumId},#{answerType},#{studentScore},now())")
    int add(StudentAnswer studentAnswer);

    /**
     * 根据学号判断该学生是否答题
     * @param studentNum
     * @return
     */
    @Select("SELECT count(*) FROM student_answer WHERE student_num_id=#{studentNum}")
    int exist(Integer studentNum);

}
